<?php
class SmsTaskModule extends BaseModel
{
    private $_table_sms_task  = "sms_task";
    private $_table_sms_task_log  = "sms_task_log";


    public function __construct($db_choose = "default"){
        parent::__construct($db_choose);
    }

    public function getSmsTaskList($where = array(),$field='*',$order='id desc',$offset = 0,$limit = 10) {
        $list = $this->table($this->_table_sms_task)->field($field)->where($where)->order($order)->limit($offset,$limit)->select();
        if (empty($list)) {
            $list = array();
        }
        return $list;
    }
    public function getSmsTaskCount($where = array()) {
        $count = $this->table($this->_table_sms_task)->where($where)->count();
        return $count;
    }
    public function getSmsTaskById($id){
        $where = array('id' => $id);
        return $this->table($this->_table_sms_task)->where($where)->find();
    }
    public function getSmsTaskByKey($key){
        $where = array('key' => $key);
        return $this->table($this->_table_sms_task)->where($where)->find();
    }
    public function addSmsTask($data) {
        return $this->table($this->_table_sms_task)->add($data);
    }
    public function saveSmsTask($id,$data) {
        if (empty($id)){
            return false;
        }
        $where['id'] = $id;
        return $this->table($this->_table_sms_task)->where($where)->save($data);
    }


    public function addSmsTaskLog($data) {
        return $this->table($this->_table_sms_task_log)->add($data);
    }
}
